package butines.core.game.util;

import butines.core.Timer;

public class Regulator {

	private float updatePeriod;
	private float nextUpdateTime;
	private Timer timer;

	public Regulator(Timer timer, int updatePerSeconds) {
		this.timer = timer;
		this.updatePeriod = timer.getResolution() / updatePerSeconds;
	}
	
	public boolean isReady() {
		if (nextUpdateTime < timer.getFrameTime()) {
			nextUpdateTime = timer.getFrameTime() + updatePeriod;
			return true;
		}
		return false;
	}
	
}
